﻿<%@ page language="java"  pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>系统管理</title>
<link href="<%=path %>/styles/main.css" rel="stylesheet" type="text/css" />
<link href="<%=path%>/js/jpage/theme/black/css/jpage.css"  rel="stylesheet" type="text/css" media="screen">
<link href="<%=path %>/js/dialog/skin/ymPrompt.css"  rel="stylesheet" id='skin' type="text/css"/> 

<script type="text/javascript" src="<%=path%>/js/main.js"></script>
<script type="text/javascript" src="<%=path%>/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/jpage/jquery.jpage.js"></script>
<script type="text/javascript" src="<%=path %>/js/dialog/ymPrompt.js" ></script>

<script language="javascript">
	<!--	
	function loadPage(){
		var deptId=document.getElementById("deptId").value;
		var empId=document.getElementById("empId").value;
		var cols=["userId","empName","userName"];
		$("#container,#PagerTable,#RightMns").jpage({ proxyUrl:'<%=path%>/system/user/listPage.do',
												ajaxParam:{'deptId':deptId,'empId':empId},
												groupSize:4,cols:cols,isView:true,
												hasCheck:true,keyField:'userId'});
	}
	$(document).ready(loadPage);
	
	
	function view(id){
		ymPrompt.win({title:'用户详细',width:600,height:500,fixPosition:true,iframe:{id:'myId',name:'myName',src:'<%=path%>/system/user/view.do?userId='+id}});
	}
	function update(){
		var id=getCheckedId();
		if(id==null || id==""){
			ymPrompt.alert({title:'提示对话框',message:'请您选择要修改的记录！'});			
		}else{
			view(id);
		}
	}
	function add(){
		ymPrompt.win({title:'用户详细',width:600,height:500,fixPosition:true,iframe:{id:'myId',name:'myName',src:'<%=path%>/system/user/add.do'}});
	}
	function del(){		
		ymPrompt.confirmInfo({title:'确认信息',message:'您是否要删除该记录？',handler:confirmhandler});
	}
	
	function confirmhandler(type){
		if(type=="ok"){		
			var userId=getCheckedId();
			$.post("<%=path %>/system/user/del.do",
			      	{userId:userId},
			      	function(data){      		 
			      		if(data=="delete"){		               
				            ymPrompt.succeedInfo({message:'删除成功！'});
				            loadPage();               	
			            }else{
			               	ymPrompt.errorInfo({title:'错误信息',message:'删除失败！'})             
			            }
			      	},"string");
		 }else{return ;}
	}
	function getEmpList(obj){
		var deptId=obj.value;		
		$('#empId').empty();
		var selectContainer = $('#empId');
		$.getJSON("<%=path%>/system/employee/getEmpList.do?deptId="+deptId, function(data){
			selectContainer.append("<option value=''></option>");
	  		$.each(data.list, function(i,item){	  			
	  			var option = $('<option></option>').text(item.empName).val(item.empId);
	  			selectContainer.append(option);	    	
	  		});
		});
	}
	var menuIndex=4;
	var topMenuIndex=1;
	//-->
</script>	
</head>
<body>	
<div id="container">
	<%@ include file="../common/Header.jsp"%>
	<%@ include file="Menu.jsp"%>	
	<form method="post">
	<div id="Content">
	    <table  class="TableSearch" width="100%" border="0" cellspacing="3" cellpadding="0">
			<tr>		
				<td width="80" nowrap="nowrap">所属部门</td>
			    <td width="200">
			    	<s:select  emptyOption="true" name="deptId" style="width:200px;" onchange="getEmpList(this)" list="deptList"  listKey="orgId" listValue="orgName" />
			    </td>
				<td width="50" nowrap="nowrap"></td>
				<td width="80" nowrap="nowrap">人员名称</td>
				<td width="200">
					<select name="empId" id="empId" class="DropDown"></select>
				
				</td>
				<td width="50"></td>
				<td width="120">
					<tt><input name="Submit42" type="button"  onclick="loadPage()" class="But" value="检索" /></tt>
				</td>
				<td >&nbsp;</td>
			</tr>
		</table>
		<table  class="TableList" width="100%" border="0" cellpadding="0" cellspacing="0">
			<thead>
				<tr>
				  <th width="30" height="26" nowrap="nowrap">选择</th>
	              <th width="80" nowrap="nowrap">用户ID</th>
	              <th nowrap="nowrap">用户名称</th>
	              <th width="140" nowrap="nowrap">登陆账号</th>
	              <th width="60" nowrap="nowrap">基本信息</th>               
	            </tr>
			</thead>
			<tbody id="PagerTable"></tbody>		
		</table>
		<div  id="ListToolbar">
			<div style="float:left">
			    <tt><input class="But" type="button" name="BtnAdd" value="增加" onclick="add()" /> </tt> 
				<tt><input class="But" type="button" name="BtnDel" value="删除" onclick="del()"/></tt>
				<tt><input class="But" type="button" name="BthUpdate" value="修改" onclick="update()"/></tt>
	        </div>			
		    <div id="RightMns" style="float:right"></div> 
		</div>
	</div>
	</form>	
</div>
</body>
</html>
